package com.movitech.mobile.cz.base.sys.controller;


import com.movitech.mobile.cz.base.common.util.CommonConstants;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.plugins.Page;
import com.movitech.mobile.cz.base.sys.entity.SysArea;
import com.movitech.mobile.cz.base.sys.service.SysAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
 * <p>
 * SysArea 前端控制器
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-04-10
 */
@RestController
@RequestMapping("/v1/sysArea")
@Api(value = "省市区基础操作接口", description = "省市区基础操作接口")
public class SysAreaController {
    @Autowired
    private SysAreaService sysAreaService;

    @GetMapping("/public/allList")
    @ApiOperation(
            value = "获取所有省市区接口",
            notes = "获取所有省市区接口",
            response = SysArea.class
    )
    public RestReturnResult allList() {
        RestReturnResult<Object> hResult = new RestReturnResult<Object>(CommonConstants.FAIL, "", CommonConstants.ERROR_CODES[0], CommonConstants.ERROR_DESCS[0]);
        try {
            hResult = sysAreaService.allList();
        } catch (Exception e) {
            hResult = new RestReturnResult<Object>(CommonConstants.FAIL, "", CommonConstants.ERROR_CODES[0], e.getMessage());
        }
        return hResult;
    }

//    @PostMapping("/searchList/{pageNumber}")
//    @ApiOperation(
//            value = "省市区列表查询接口",
//            notes = "省市区列表查询接口",
//            response = SysArea.class
//    )
//    public RestReturnResult searchList(@RequestBody SysArea sysArea,
//                @ApiParam(value = "分页页数")@PathVariable Integer pageNumber) {
//        RestReturnResult restReturnResult = RestReturnResult.success();
//        Page<SysArea> page = new Page<>();
//        page.setCurrent(pageNumber);
//        EntityWrapper wrapper = new EntityWrapper<>();
//        wrapper.setEntity(sysArea);
//        page = sysAreaService.selectPage(page,wrapper);
//        restReturnResult.setData(page);
//        return restReturnResult;
//    }
//
//    @GetMapping("/getSysArea/{id}")
//    @ApiOperation(
//            value = "省市区对象ID获取接口",
//            notes = "省市区对对象ID获取接口",
//            response = SysArea.class
//    )
//    public RestReturnResult addSysArea(@PathVariable String id) {
//        RestReturnResult restReturnResult = RestReturnResult.success();
//        SysArea sysArea = sysAreaService.selectById(id);
//        restReturnResult.setData(sysArea);
//        return restReturnResult;
//    }
//
//    @PostMapping("/add")
//    @ApiOperation(
//            value = "省市区添加接口",
//            notes = "省市区添加接口",
//            response = SysArea.class
//    )
//    public RestReturnResult add(@RequestBody SysArea sysArea) {
//        RestReturnResult restReturnResult = RestReturnResult.success();
//        sysAreaService.insert(sysArea);
//        restReturnResult.setData(sysArea);
//        return restReturnResult;
//    }
//
//    @PutMapping("/update")
//    @ApiOperation(
//            value = "省市区更新接口",
//            notes = "省市区更新接口",
//            response = SysArea.class
//    )
//    public RestReturnResult update(@RequestBody SysArea sysArea) {
//        RestReturnResult restReturnResult = RestReturnResult.success();
//        sysAreaService.updateById(sysArea);
//        restReturnResult.setData(sysArea);
//        return restReturnResult;
//    }
//
//    @DeleteMapping("/delete/{id}")
//    @ApiOperation(
//            value = "省市区通过ID删除接口",
//            notes = "省市区通过ID删除接口",
//            response = SysArea.class
//    )
//    public RestReturnResult update(@PathVariable String id) {
//        RestReturnResult restReturnResult = RestReturnResult.success();
//        sysAreaService.deleteById(id);
//        return restReturnResult;
//    }


}

